package com.jfree.feign.fallbackFactory;

import com.jfree.entity.general.User;
import com.jfree.feign.ServiceApiFeign;
import feign.hystrix.FallbackFactory;
import org.springframework.stereotype.Component;

@Component
public class ServiceApiFeignFallbackFactory implements FallbackFactory<ServiceApiFeign> {


    @Override
    public ServiceApiFeign create(Throwable throwable) {

        /**FallbackFactory的默认实现
       Default d=new Default();//logger.log(Level.FINE, "fallback due to: " + cause.getMessage(), cause);
        对异常分类处理，记录。
         */
        System.out.println(throwable);
        return new ServiceApiFeign() {
            @Override
            public User user(User user) {
                user.setName("fallback name");
                return user;
            }

            @Override
            public String getException(Integer id) {
                return "FALL BACK --->" + id;
            }

            @Override
            public String test(Integer id) {
                return " test fall-->" + id;
            }

            @Override
            public String test1(Integer id) {
                return "test fall-->1" + id.toString();
            }

            @Override
            public String test2(Integer id) {
                return "test fall-->2" + id.toString();
            }

            @Override
            public String test3(Integer id) {
                return "test fall-->3" + id.toString();
            }

            @Override
            public User test4(User user) {
                User user1 = new User();
                user1.setName("test fall-->---4");
                return user1;
            }

            @Override
            public User test5(User user) {
                User user1 = new User();
                user1.setName("test fall-->---5");
                return user1;
            }
        };
    }
}
